package com.bdqn.controller;


import com.bdqn.entity.CommonResult;
import com.bdqn.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.getPaymentById(id);
    }

    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
    // openFeign 中是集成了 ribbon，它是使用 ribbon 实现负载均衡。服务消费者使用openfeign 调用服务提供者默认是等待 1 秒钟(即 1秒钟 feign 就要拿到响应数据,
        // 超过 1秒钟就会报错)
        return paymentFeignService.paymentFeignTimeout();
    }
}
